﻿using Sherwood.Content;
using Sherwood.Content.UpdateServices;
using System.Linq;

namespace Sherwood.Samples.ArticleMeta
{
    public class ArticleMetaSearchDocumentModifier :ISearchDocumentModifier
    {
        public void Fill(ISearchDocument searchDocument, IRecord record)
        {
            var document = (ArticleSearchDocument) searchDocument;
            foreach (var meta in record.Metas.OfType<ArticleMeta>())
            {
                document.Body += meta.Body;
                document.Author += meta.Author;
                document.PublishDate = meta.PublishDate;
            }
        }
    }
}